package com.auto.sns.core.action;

import java.util.List;

import com.auto.oa.user.domain.OaUserInfoExtend;
import com.auto.sns.core.domain.SnsCoreUserRelaMapExtend;
import com.auto.sns.core.service.SnsCoreServiceFactory;
import com.auto.tools.AutoUtils;
import com.opensymphony.xwork2.Action;
import com.system.common.BaseAction;
import com.system.common.Page;
import com.system.util.BeanUtil;

public class SnsCoreUserAction extends BaseAction {

	private static final long serialVersionUID = -572239339856228025L;
	
	public String queryPageListMyOrgUser(){
		try {
			String userCode = AutoUtils.getUserCode();
			String userOrgCode = AutoUtils.getUserOrgCode(userCode);
			
			Page page = null;
			if(BeanUtil.isBlank(getRequest().getParameter("pageIndex"))){
				page = new Page(1, 10);
			}else{
				page = getPage();
			}
			
			List<OaUserInfoExtend> myOrgUserList = SnsCoreServiceFactory.snsCoreUserService.queryPageListUserInfoByOrgCode(userOrgCode, page);
			
			getRequest().setAttribute("myOrgUserList", myOrgUserList);
			getRequest().setAttribute("page", page);
			
			return Action.SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();
			
			return Action.ERROR;
		}
	}
	
	public String queryPageListMyCareUser(){
		try {
			String userCode = AutoUtils.getUserCode();
			
			Page page = null;
			if(BeanUtil.isBlank(getRequest().getParameter("pageIndex"))){
				page = new Page(1, 10);
			}else{
				page = getPage();
			}
			
			SnsCoreUserRelaMapExtend snsCoreUserRelaMapExtend = new SnsCoreUserRelaMapExtend();
			snsCoreUserRelaMapExtend.setScurSrcUserCode(userCode);
			
			List<SnsCoreUserRelaMapExtend> myOrgUserList = SnsCoreServiceFactory.snsCoreUserService.queryPageListMyCareUser(snsCoreUserRelaMapExtend, page);
			
			getRequest().setAttribute("myOrgUserList", myOrgUserList);
			getRequest().setAttribute("page", page);
			
			return Action.SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();
			
			return Action.ERROR;
		}
	}
	
	public String queryPageListCareMeUser(){
		try {
			String userCode = AutoUtils.getUserCode();
			
			Page page = null;
			if(BeanUtil.isBlank(getRequest().getParameter("pageIndex"))){
				page = new Page(1, 10);
			}else{
				page = getPage();
			}
			
			SnsCoreUserRelaMapExtend snsCoreUserRelaMapExtend = new SnsCoreUserRelaMapExtend();
			snsCoreUserRelaMapExtend.setScurRelaUserCode(userCode);
			
			List<SnsCoreUserRelaMapExtend> myOrgUserList = SnsCoreServiceFactory.snsCoreUserService.queryPageListMyCareUser(snsCoreUserRelaMapExtend, page);
			
			getRequest().setAttribute("myOrgUserList", myOrgUserList);
			getRequest().setAttribute("page", page);
			
			return Action.SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();
			
			return Action.ERROR;
		}
	}

}
